package com.ruoyi.project.sale.contract.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.sale.contract.domain.Fyxszl;
import com.ruoyi.project.sale.contract.service.IFyxszlService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 销售合同Controller
 * 
 * @author frank
 * @date 2024-08-20
 */
@RestController
@RequestMapping("/sale/contract/fyxszl")
public class FyxszlController extends BaseController
{
    @Autowired
    private IFyxszlService fyxszlService;

    /**
     * 查询销售合同列表
     */
    @PreAuthorize("@ss.hasPermi('sale/contract:fyxszl:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fyxszl fyxszl)
    {
        startPage();
        List<Fyxszl> list = fyxszlService.selectFyxszlList(fyxszl);
        return getDataTable(list);
    }

    /**
     * 导出销售合同列表
     */
    @PreAuthorize("@ss.hasPermi('sale/contract:fyxszl:export')")
    @Log(title = "销售合同", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Fyxszl fyxszl)
    {
        List<Fyxszl> list = fyxszlService.selectFyxszlList(fyxszl);
        ExcelUtil<Fyxszl> util = new ExcelUtil<Fyxszl>(Fyxszl.class);
        util.exportExcel(response, list, "销售合同数据");
    }

    /**
     * 获取销售合同详细信息
     */
    @PreAuthorize("@ss.hasPermi('sale/contract:fyxszl:query')")
    @GetMapping(value = "/{fyXszloid}")
    public AjaxResult getInfo(@PathVariable("fyXszloid") String fyXszloid)
    {
        return success(fyxszlService.selectFyxszlByFyXszloid(fyXszloid));
    }

    /**
     * 新增销售合同
     */
    @PreAuthorize("@ss.hasPermi('sale/contract:fyxszl:add')")
    @Log(title = "销售合同", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fyxszl fyxszl)
    {
        return toAjax(fyxszlService.insertFyxszl(fyxszl));
    }

    /**
     * 修改销售合同
     */
    @PreAuthorize("@ss.hasPermi('sale/contract:fyxszl:edit')")
    @Log(title = "销售合同", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fyxszl fyxszl)
    {
        return toAjax(fyxszlService.updateFyxszl(fyxszl));
    }

    /**
     * 删除销售合同
     */
    @PreAuthorize("@ss.hasPermi('sale/contract:fyxszl:remove')")
    @Log(title = "销售合同", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fyXszloids}")
    public AjaxResult remove(@PathVariable String[] fyXszloids)
    {
        return toAjax(fyxszlService.deleteFyxszlByFyXszloids(fyXszloids));
    }
}
